//读取流readStream
var fs = require('fs');
var data = '';

var readStream = fs.createReadStream('input.txt');
readStream.setEncoding('UTF8');

readStream.on('data',function(chunk){
	data+=chunk;
})
readStream.on('end',function(){
	console.log(data);
})

readStream.on('error',function(err){
	console.log(err.stack);
})

console.log('程序执行完毕');


//写入流writeStream
var writeData = "goodbye node!";
var writeStream = fs.createWriteStream('output.txt');
writeStream.write(writeData,'UTF8');
writeStream.end();
writeStream.on('finish',function(){
	console.log('写入完成');
});
writeStream.on('error',function(err){
	console.log(err.stack);
});


